import { Navigate, Route, Routes } from "react-router-dom"
import Home from '@/pages/home'
import Login from '@/pages/login'
import TableList from '@/pages/table-list'
import DetailPage from '@/pages/table-list/detail-page'
import Anchor from '@/pages/anchor'
import UploadExcel from '@/pages/upload-excel'
import MoveForm from '@/pages/move-form'
import AutoColumns from '@/pages/auto-columns'
import UpdateCell from '@/pages//update-cell'
import Error from '@/pages/404'
import Datepicker from '@/pages/datepicker'
import UseState from '@/pages/use-state'
import UseRedux from '@/pages/use-redux'
import Index from '@/pages/home/pages/home'
import Manage from '@/pages/home/pages/manage'
import Checkbox from '@/pages/checkbox'
import Card from '@/pages/card-page'
import Badge from '@/pages/badge'
import MagnifyingGlass from "@/pages/magnifying-glass"
import LadderBgColor from "@/pages/ladderTable"
import LayoutContent from "./layout"
import RenderTable from '@/pages/render-table'
import { useEffect } from "react"
import DwsLog from '@/pages/ews-log'
import TestLayout from '@/pages/testLayout'
import Echarts from '@/pages/echarts'
import Dayjs from '@/pages/dayjs'
import MergeCell from '@/pages/merge-cell'
import Animation from "./pages/animation"
import withComponens from "./hooks/with.hooks"
import Screen from "./pages/screen"
import KeyDown from '@/pages/keydown'
import Table from '@/pages/table-header'
import AntConfig from '@/pages/config-provider'
import Cookie from 'js-cookie'
import Context from "./pages/use-context"
const WithDws = withComponens(DwsLog)
const App = () => {
  // 设置cookie 设置过期时间   expires ： 浏览器识别天数
  Cookie.set('name', 'value', { expires: 1 })
  // 获取cookie
  Cookie.get('name')
  // 删除cookie
  // Cookie.remove('name')
  // 为浏览器添加title
  useEffect(() => {
    document.title = 'React 学习'
  }, [])
  const string = '阳阳'
  // console.log(escape(string), '编码');
  // console.log(unescape(string), '解码');
  // 不能编码；，/？@&=+非标准字符  不会破坏url的原本结构
  // console.log(encodeURI(string));
  // console.log(decodeURI(string));
  // 解析url参数  可以编码所有非标准字符
  encodeURIComponent(location.search.split('?')[1])
  decodeURIComponent(encodeURIComponent(location.search.split('?')[1]))
  // console.log(location);
  
  return (
      <Routes>
        <Route path='/' element={<LayoutContent />}>
          <Route path='/' element={<Navigate to='/home/index' />} />
          <Route path='/home/index' element={<Index />} />
          <Route path='/home/manage' element={<Manage />} />
        </Route>

        {/* 子集路由 */}
        <Route path='/home' element={<Home />}>
          <Route path='/home' element={<Navigate to='/home/index' />} />
          <Route path='/home/index' element={<Index />} />
          <Route path='/home/manage' element={<Manage />} />
        </Route>

        <Route path='/login' element={<Login />} />
        <Route path='/dws' element={<WithDws title={'小蓝'} />} />
        <Route path='/card' element={<Card />} />
        <Route path='/table-list' element={<TableList />} />
        <Route path='/table-list/detail-page' element={<DetailPage />} />
        <Route path='/anchor' element={<Anchor />} />
        <Route path='/upload-excel' element={<UploadExcel />} />
        <Route path='/move-form' element={<MoveForm />} />
        <Route path='/auto-columns' element={<AutoColumns />} />
        <Route path='/update-cell' element={<UpdateCell />} />
        <Route path='/datepicker' element={<Datepicker />} />
        <Route path='/use-state' element={<UseState />} />
        <Route path='/use-redux' element={<UseRedux />} />
        <Route path='/checkbox' element={<Checkbox />} />
        <Route path='/badge' element={<Badge />} />
        <Route path='/magnifyingGlass' element={<MagnifyingGlass />} />
        <Route path='/ladderBgColor' element={<LadderBgColor />} />
        <Route path='/renderTable' element={<RenderTable />} />
        <Route path='/testLayout' element={<TestLayout />} />
        <Route path='/echarts' element={<Echarts />} />
        <Route path='/dayjs' element={<Dayjs />} />
        <Route path='/mergeCell' element={<MergeCell />} />
        <Route path='/animation' element={<Animation />} />
        <Route path='screen' element={<Screen />} />
        <Route path='keydown' element={<KeyDown />} />
        <Route path='table' element={<Table />} />
        <Route path='antConfig' element={<AntConfig />} />
        <Route path='context' element={<Context />} />
        <Route path='*' element={<Error />} />
      </Routes>
  )
}

export default App
